#ifndef __TEST1_CSBUF_H__
#define __TEST1_CSBUF_H__
// 本文件由自动工具 proto.py 自动生成，请勿修改
// filename test1_csbuf.h
// package test

#include "CsbufParser.h"
#include "CsbufMessage.h"

namespace test {

// message Head
class Head: public CsbufMessage
{
public:
	uint32_t a;
	std::string b;

	Head()
	: CsbufMessage(1000)
	{
		a = 0;
		b = "";
	}

	void Marshal(CsbufParser& writer)
	{
		writer.setUint32(a, 1);
		writer.setString(b, 2);
	}

	void Unmarshal(CsbufParser& reader)
	{
		a = reader.getUint32(1);
		b = reader.getString(2);
	}
};
// message Test1
class Test1: public CsbufMessage
{
public:
	uint8_t a_t1;
	uint32_t at_2;
	std::string at3_;
	std::vector<uint32_t> t4;
	std::vector<std::string> t5;
	Head t6;
	std::vector<Head> t7;

	Test1()
	: CsbufMessage(2001)
	{
		a_t1 = 0;
		at_2 = 0;
		at3_ = "";
	}

	void Marshal(CsbufParser& writer)
	{
		writer.setUint8(a_t1, 1);
		writer.setUint32(at_2, 2);
		writer.setString(at3_, 3);
		uint8_t countt4 = (uint8_t)t4.size();
		writer.setArray(countt4, 4);
		for (uint8_t i=0; i<countt4; ++i)
		{
			writer.setUint32(t4[i], 0);
		}
		uint8_t countt5 = (uint8_t)t5.size();
		writer.setArray(countt5, 5);
		for (uint8_t i=0; i<countt5; ++i)
		{
			writer.setString(t5[i], 0);
		}
		writer.setMessage(6);
		t6.Marshal(writer);
		writer.endSetMessage();
		uint8_t countt7 = (uint8_t)t7.size();
		writer.setArray(countt7, 7);
		for (uint8_t i=0; i<countt7; ++i)
		{
			writer.setMessage(0);
			t7[i].Marshal(writer);
			writer.endSetMessage();
		}
	}

	void Unmarshal(CsbufParser& reader)
	{
		a_t1 = reader.getUint8(1);
		at_2 = reader.getUint32(2);
		at3_ = reader.getString(3);
		uint8_t countt4 = reader.getArray(4);
		for (uint8_t i=0; i<countt4; ++i)
		{
			t4.push_back(reader.getUint32(0));
		}
		uint8_t countt5 = reader.getArray(5);
		for (uint8_t i=0; i<countt5; ++i)
		{
			t5.push_back(reader.getString(0));
		}
		reader.getMessage(6);
		t6.Unmarshal(reader);
		reader.endGetMessage();
		uint8_t countt7 = reader.getArray(7);
		for (uint8_t i=0; i<countt7; ++i)
		{
			Head msg;
			reader.getMessage(0);
			msg.Unmarshal(reader);
			reader.endGetMessage();
			t7.push_back(msg);
		}
	}
};
// message Test2
class Test2: public CsbufMessage
{
public:
	uint8_t a_t1;
	uint32_t at_2;
	std::string at3_;
	Head t6;
	std::vector<Head> t7;

	Test2()
	: CsbufMessage(2002)
	{
		a_t1 = 0;
		at_2 = 0;
		at3_ = "";
	}

	void Marshal(CsbufParser& writer)
	{
		writer.setUint8(a_t1, 1);
		writer.setUint32(at_2, 2);
		writer.setString(at3_, 3);
		writer.setMessage(6);
		t6.Marshal(writer);
		writer.endSetMessage();
		uint8_t countt7 = (uint8_t)t7.size();
		writer.setArray(countt7, 7);
		for (uint8_t i=0; i<countt7; ++i)
		{
			writer.setMessage(0);
			t7[i].Marshal(writer);
			writer.endSetMessage();
		}
	}

	void Unmarshal(CsbufParser& reader)
	{
		a_t1 = reader.getUint8(1);
		at_2 = reader.getUint32(2);
		at3_ = reader.getString(3);
		reader.getMessage(6);
		t6.Unmarshal(reader);
		reader.endGetMessage();
		uint8_t countt7 = reader.getArray(7);
		for (uint8_t i=0; i<countt7; ++i)
		{
			Head msg;
			reader.getMessage(0);
			msg.Unmarshal(reader);
			reader.endGetMessage();
			t7.push_back(msg);
		}
	}
};
}
#endif
